package com.lineage.server.command.executor;

import com.lineage.server.datatables.ItemTable;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.StringTokenizer;

public class L1InvGfxId implements L1CommandExecutor {
  public static L1CommandExecutor getInstance() {
    return new L1InvGfxId();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      StringTokenizer st = new StringTokenizer(arg);
      int gfxid = Integer.parseInt(st.nextToken(), 10);
      int count = Integer.parseInt(st.nextToken(), 10);
      int i = 0;
      while (i < count) {
        L1ItemInstance item = ItemTable.get().createItem(40005);
        item.getItem().setGfxId(gfxid + i);
        item.getItem().setName(String.valueOf(gfxid + i));
        pc.getInventory().storeItem(item);
        i++;
      } 
    } catch (Exception exception) {
      pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.valueOf(String.valueOf(cmdName)) + " 请输入 id 出现的数量。"));
    } 
  }
}
